<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./node_modules/vue/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <router-link to="/home">主页</router-link>
        <router-link to="/product/123">产品详情1</router-link>
        <router-link to="/product/456">产品详情2</router-link>
        <router-view></router-view>
    </div>
    <script src="./node_modules/vue/dist/vue.js"></script>
    <script src="./node_modules/vue-router/dist/vue-router.js"></script>
    <script>
        let routes = [{
            path: "/home",
            component: () => Promise.resolve({
                template: `<h1>主页</h1>`
            })
        }, {
            path: "/product/:productId",
            component: () => import("./Product.js")
        }]
        let router = new VueRouter({
            routes
        })
        //创建Vue实例,得到 ViewModel
        var vm = new Vue({
            router,
            el: '#app',
        });
    </script>
</body>

</html>